home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / dumpgraf.cq / dump_gra.c
C/C++ Source or Header  |  1985-06-03  |  2KB  |  49 lines

  1. /*                            DUMP GRAPHICS
  2. **************************************************************************
  3. *                       --------------------------                       *
  4. *                      |    Max W. Medley, Jr.    |                      *
  5. *                      |   13550 San Rafael Dr.   |                      *
  6. *                      |  Largo, Florida  33544   |                      *
  7. *                      |   (813) - 595 - 5051     |                      *
  8. *                       --------------------------                       *
  9. *                                                                        *
  10. * Dump graphic screen (high resolution) to an MX-80 printer with the     *
  11. * GRAFTRAX80 rom.  STTY should be used to set all options OFF for $lpt.  *
  12. * All characters must be passed directly to the printer without change.  *
  13. * Default value for tab is used to position the output. If desired, the  *
  14. * position may be changed by either setting a different tab stop or      *
  15. * using spaces (20h).                                                    *
  16. **************************************************************************
  17. */
  18. #include <stdio.h>
  19.  
  20. main()
  21. {
  22.     register int row, j, cr;
  23.     unsigned int fp,bit,dot,col;
  24.     char *pd,chr;
  25.     set_extra_segment(0xb800);
  26.     fp = fopen("$lpt", "w");                /* open printer for write */
  27.     putc(0x0a,fp); putc(0x0a,fp); putc(0x0a,fp); putc(0x0a,fp); putc(0x0d,fp);
  28.     putc(0x1b,fp); putc(0x41,fp); putc(0x08,fp);    /* 8/72 lines per inch */
  29.     for(cr=0; cr<640; cr += 8) {            /* Column loop */
  30.         putc(0x09,fp);                        /* Tab to column and begin dump */
  31.         putc(0x1b,fp); putc(0x4b,fp); putc(0x90,fp); putc(0x01,fp); /* 480 mode next 400 */
  32.         for(row=199; row>=0; row--) {        /* Row loop */
  33.             chr = 0;                        /* Initialize graphics character */
  34.             bit = 0x80;                        /* Initialize bit mask */
  35.             for(j=0; j<8; j++) {            /* read 8 dots into graphics character */
  36.                 col = cr + j;
  37.                 pd = (0x28 * (row & 0xfe)) + (col >> 3);    /* Address within regen area */
  38.                 if(row & 1)
  39.                     pd += 0x2000;                            /* Odd scan */
  40.                 dot = (@pd & (0x80 >> (7 & (col & 0xff))));    /* Mask display byte */
  41.                 chr += ((dot) ? bit : 0);
  42.                 bit >>= 1;                    /* Shift mask */
  43.             }
  44.             putc(chr,fp); putc(chr,fp);        /* Two graphics characters */
  45.         }
  46.         putc(0x0a,fp); putc(0x0d,fp);        /* LF - CR */
  47.     }
  48. }
  49.